package gao.xaiolei.dao;

import gao.xaiolei.enity.TaskReceiverId;
import gao.xaiolei.enity.TaskReceiverView;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("ITaskReceiverViewDao")
public interface ITaskReceiverViewDao extends JpaRepository<TaskReceiverView,TaskReceiverId> {

    @Query(value="from TaskReceiverView where id.TR_USER_ID=:userId and statusNum>:status",
            countQuery = "SELECT count(*) from TaskReceiverView where id.TR_USER_ID=:userId and statusNum>:status")
    public Page<TaskReceiverView> findAllByReceiverAndStatusNumAfterOrderByCreateDateDesc(@Param("userId") String userId,
                                                                                          @Param("status") Integer status,
                                                                                          Pageable pageable);

}
